﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace ShadowGame
{
    public class Clue : GameComponent
    {
        private Texture2D clueTexture;
        private ClueDirection clueDirection;
        private string animation;
        private int timer;
        private int started = -1;
        private bool firstIntersect = true;

        public Clue(ContentManager content, string animation) : base(null)
        {
            this.animation = animation;
            clueTexture = content.Load<Texture2D>(@"Images\info");
            animations.Add("idle", new Animation(clueTexture, 18, 18, new Rectangle(0, 0, 18, 18), 1, "idle"));
            animations["idle"].LoopAnimation = true;
            animations["idle"].FrameLength = 0.5f;
            frameWidth = 18;
            frameHeight = 18;
            drawDepth = 0.825f;
            enabled = false;
            PlayAnimation("idle");
            CollisionRectangle = new Rectangle(0, 0, 18, 18);

            clueDirection = new ClueDirection(content, animation);
        }

        public ClueDirection Direction { get { return clueDirection; } }
        public int Started { get { return started; } set { started = value; } }
        public bool FirstIntersect { get { return firstIntersect; } set { firstIntersect = value; } }

        public override void Update(GameTime gameTime)
        {
            timer = (int)gameTime.TotalGameTime.TotalMilliseconds - started;
            if (timer >= 2000)
            {
                timer = 0;
                started = -1;
                clueDirection.Enabled = false;
                enabled = true;
            }
            base.Update(gameTime);
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            clueDirection.Draw(spriteBatch);
            base.Draw(spriteBatch);
        }
    }
}
